from datetime import timedelta
import os
class BaseConfig:
    SECRET_KEY = 'zhongxxxxuuuu'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # session的过期时间
    # PERMANENT_SESSION_LIFETIME = timedelta(days=7)
    PER_PAGE_COUNT = 10
    # UPLOAD_IMAGE_PATH= r'E:\file_upload'
    # UPLOAD_IMAGE_PATH= r'E:\file_upload'
    UPLOAD_IMAGE_PATH= r'/home/zhiliao/media'
    # UPLOAD_IMAGE_PATH= r'/home/zhiliao/pythonbbs/media'




class DevelopmentConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = 'mysql://root:12345678@127.0.0.1:3306/pythonbbs?charset=utf8mb4'
    # 邮箱配置
    MAIL_SERVER = 'smtp.163.com'
    MAIL_USE_SSL = True
    MAIL_PORT = 465
    MAIL_USERNAME = 'zxh20210o@163.com'
    MAIL_PASSWORD = 'LPqgUekGXKiW9GKV'
    MAIL_DEFAULT_SENDER = 'zxh20210o@163.com'

    # 缓存配置
    # 缓存类型
    CACHE_TYPE = 'RedisCache'
    # 缓存服务器
    CACHE_REDIS_HOST = '127.0.0.1'
    # CACHE_REDIS_HOST = '192.168.1.5'
    # 缓存密码
    CACHE_REDIS_PORT = 6379
    # 缓存的键的前缀
    CACHE_KEY_PREFIX = 'pythonbbs:'
    # 缓存过期时间
    CACHE_REDIS_DEFAULT_TIMEOUT = 300

    # CACHE_TYPE = 'MemcachedCache'
    # CACHE_MEMCACHED_SERVERS = ['127.0.0.1:11211']
    # CACHE_KEY_PREFIX = 'zx'
    # CACHE_DEFAULT_TIMEOUT = 300
    # CACHE_MEMCACHED_SERIALIZATION = 'json'
    # celery 配置
    CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
    CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'

    # 头像存储路径
    AVATARS_SAVE_PATH = os.path.join(BaseConfig.UPLOAD_IMAGE_PATH, 'avatars')


class TestingConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = 'mysql://[测试环境服务器数据库用户名]:[测试环境服务器数据库密码]@[测试环境服务器IP]:[测试环境服务器数据库端口号]/pythonbbs?charset=utf8mb4'


class ProductionConfig(BaseConfig):
    # SQLALCHEMY_DATABASE_URI = 'mysql://[生产环境服务器数据库用户名]:[生产环境服务器数据库密码]@[生产环境服务器IP]:[生产环境服务器数据库端口号]/pythonbbs?charset=utf8mb4'
    SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@192.168.1.8:3306/pythonbbs?charset=utf8mb4'

    # 邮箱配置
    MAIL_SERVER = 'smtp.163.com'
    MAIL_USE_SSL = True
    MAIL_PORT = 465
    MAIL_USERNAME = 'zxh20210o@163.com'
    MAIL_PASSWORD = 'LPqgUekGXKiW9GKV'
    MAIL_DEFAULT_SENDER = 'zxh20210o@163.com'

    # 缓存配置
    # 缓存类型
    CACHE_TYPE = 'RedisCache'
    # 缓存服务器
    CACHE_REDIS_HOST = '127.0.0.1'
    # CACHE_REDIS_HOST = '192.168.1.5'
    # 缓存密码
    CACHE_REDIS_PORT = 6379
    # 缓存的键的前缀
    CACHE_KEY_PREFIX = 'pythonbbs:'
    # 缓存过期时间
    CACHE_REDIS_DEFAULT_TIMEOUT = 300

    # CACHE_TYPE = 'MemcachedCache'
    # CACHE_MEMCACHED_SERVERS = ['127.0.0.1:11211']
    # CACHE_KEY_PREFIX = 'zx'
    # CACHE_DEFAULT_TIMEOUT = 300
    # CACHE_MEMCACHED_SERIALIZATION = 'json'
    # celery 配置
    CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
    CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'

    # 头像存储路径
    AVATARS_SAVE_PATH = os.path.join(BaseConfig.UPLOAD_IMAGE_PATH, 'avatars')